import axios from '@/utils/request'

// 获取图片验证码
export const getPicCode = () => {
  // 一定要写return 不然页面拿不到成功的结果
  return axios({
    url: '/captcha/image',
    method: 'GET'
  })
}

// 获取手机短信验证码
export const getMsgCode = (captchaCode, captchaKey, mobile) => {
  return axios({
    url: '/captcha/sendSmsCaptcha',
    method: 'POST',
    data: {
      form: {
        captchaCode,
        captchaKey,
        mobile
      }
    }
  })
}
// export const getMsgCode = (captchaCode, captchaKey, mobile) => {
//   return axios.post('/captcha/sendSmsCaptcha', {
//     form: {
//       captchaCode,
//       captchaKey,
//       mobile
//     }
//   })
// }

// 登录
export const login = (mobile, smsCode) => {
  // 这里只需要传过来mobile, smsCode就可以了，那两个可以不传，用默认值
  return axios({
    url: '/passport/login',
    method: 'POST',
    data: {
      form: {
        isParty: false,
        mobile,
        partyData: {},
        smsCode
      }
    }
  })
}
